﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Spymaster.Entities.Components
{
    public class HealthComponent
    {
        private int maxHealth;
        public int MaxHealth
        {
            get { return maxHealth; }
        }

        private int currentHealth;
        public int CurrentHealth
        {
            get { return currentHealth; }
            set
            {
                if (value > maxHealth)
                {
                    currentHealth = maxHealth;
                }
                else if (value < 0)
                {
                    currentHealth = 0;
                }
                else
                {
                    currentHealth = value;
                }
            }
        }

        public HealthComponent(int max)
        {
            maxHealth = max;
            currentHealth = max;
        }

        public bool isDead()
        {
            return currentHealth <= 0;
        }
    }
}
